* confirmedrunols.do JEP	04/29/15
* Program to avoid rerunning regressions if ster file already exists
* This is to be able to build the project a second time without re-running the regressions if the .ster files are already there
* Builds on confirmedrun.do

*************************** Change log ********************************** 

/*
		
*/	


cap program drop confirmedrunols
program confirmedrunols
	syntax, name(string) ster(string) rif(string) r(string) sample(varname) ctitle(string) [y(varname) controls(string) register treat(varname) rerun fe(string) cluster(string) large weight(varname)]
	if "`y'"=="" loc y "lw"
	if "`treat'"=="" loc treat "treat"
	if "`fe'"=="" loc fe "i.ccode i.time"
	if "`cluster'"=="" loc cluster "ccode"
	cap confirm file "`ster'.ster"
	if (_rc | "`rerun'"=="rerun")  {
		cgm2 `y' `treat' `fe' `controls' if `sample' , hyp(0) boot($boot) cluster(`cluster') x(`treat') i(ccode) t(time) `large'	
	}
	else {
		est use "`ster'.ster"
	}
	exportols, name(`name') ster(`ster') r(`r') `register' ctitle(`ctitle')
end
